package club.laowang.chain.validation;

import club.laowang.chain.annotation.Min;
import club.laowang.chain.execption.ValidatorException;

public class MinValidatorHandler implements ValidatorHandler{
    private Min min;

    public MinValidatorHandler(Min min) {
        this.min = min;
    }

    @Override
    public void validator(Object value, ValidatorContext context) {
        if (value instanceof Integer) {
            Integer intValue = Integer.valueOf(value.toString());
            if (intValue < min.value()) {
                context.appendError("当前值为：" + intValue + "，小于min值：" + min.value());
            }
        }
    }
}
